package hg.framework.common.utils;

/**
 * 雪花算法-全局ID
 * @author guoqifei
 * @date 2021-01-07
 */
public class SnowflakeUtils {

    private static final long WORKER_ID = 1L;
    private static final long DATA_CENTER_ID = 1L;

    private static final SnowflakeIdWorker snowflakeIdWorker;
    static {
        snowflakeIdWorker = new SnowflakeIdWorker(WORKER_ID, DATA_CENTER_ID);
    }

    /**
     * 全局ID
     * @return
     */
    public static String nextId() {
        return String.valueOf(snowflakeIdWorker.nextId());
    }

    public static void main(String[] args) {
        System.out.println("--------");
        System.out.println(SnowflakeUtils.nextId());
        System.out.println("--------");
    }
}
